#ifndef CRITICAL_SECTION_H
#define CRITICAL_SECTION_H

#include "cmsis_os.h"

#define SECTION_SAFE_FROM_TASKS for (bool flag = (vTaskSuspendAll(), true); flag; (xTaskResumeAll(), flag = false))

#define SECTION_SAFE_FROM_INTERRUPTS \
    for (bool flag = (taskENTER_CRITICAL(), true); flag; (taskEXIT_CRITICAL(), flag = false))

#endif  // CRITICAL_SECTION_H